Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /** |
||
79 | describe("Check memorycard", function() { |
||
80 | var values = [ |
||
81 | {position: "00", value: "alpaca.png"}, |
||
82 | {position: "01", value: "monkeys.png"}, |
||
83 | {position: "11", value: "monkeys.png"}, |
||
84 | {position: "12", value: "puppy.png"}, |
||
85 | {position: "22", value: "ram.png"}, |
||
86 | {position: "32", value: "ram.png"}, |
||
87 | ]; |
||
88 | var pairs = [ |
||
89 | {cardone: "00", cardtwo: "10", expected: true}, |
||
90 | {cardone: "01", cardtwo: "22", expected: false}, |
||
91 | {cardone: "02", cardtwo: "12", expected: true}, |
||
92 | {cardone: "30", cardtwo: "31", expected: false}, |
||
93 | ]; |
||
94 | // var cardids = [ |
||
95 | // {value: 0, expected: [-1, -1]}, |
||
96 | // {value: 300, expected: [-1, -1]}, |
||
97 | // {value: 1, expected: [0, 1]}, |
||
98 | // {value: 2, expected: [2, 3]}, |
||
99 | // {value: 3, expected: [4, 5]} |
||
100 | // ]; |
||
101 | |||
102 | values.forEach(function(test) { |
||
103 | describe("Get memorycard value with position " + test.position, function() { |
||
104 | it("should be value " + test.value, function () { |
||
105 | checkMemorycardvalue(test.position, test.value); |
||
106 | }); |
||
107 | }); |
||
108 | }); |
||
109 | |||
110 | pairs.forEach(function(pair) { |
||
111 | describe("Memorycard with position " + pair.cardone + " and " + pair.cardtwo, function() { |
||
112 | it("should be a pair = " + pair.expected, function() { |
||
113 | isPair(pair.cardone, pair.cardtwo, pair.expected); |
||
114 | }); |
||
115 | }); |
||
116 | }); |
||
117 | |||
118 | // cardids.forEach(function(cardid) { |
||
119 | // describe("Memorycard with value " + cardid.value, function() { |
||
120 | // it("should be have id pair = " + cardid.expected, function() { |
||
121 | // checkCardId(cardid.value, cardid.expected); |
||
122 | // }); |
||
123 | // }); |
||
124 | // }); |
||
125 | |||
126 | describe("Unshuffled cardpositions", function() { |
||
127 | it("should be default setting", function() { |
||
128 | checkResetedPosition(); |
||
129 | }); |
||
130 | }); |
||
131 | |||
132 | describe("Shuffled cardpositions", function() { |
||
133 | it("should not be default setting", function() { |
||
134 | checkShuffledPosition(); |
||
135 | }); |
||
136 | }); |
||
137 | }); |
||
138 |